<?php

namespace App\Console\Commands\WorkOrder;

use App\Enums\WorkOrder\OrderEnum;
use App\Models\OpenShop\InvestmentPromotion\OpenShopSignOrderModel;
use App\Models\WorkOrder\WorkOrderApplyMainModel;
use App\Models\WorkOrder\WorkOrderApplyManagerModel;
use App\Models\WorkOrder\WorkOrderMissionModel;
use App\Models\WorkOrder\WorkOrderRejectDetailModel;
use App\Models\WorkOrder\WorkOrderRejectModel;
use App\Service\WorkOrder\Manager\ManagerService;
use App\Service\WorkOrder\Mission\MissionEngineService;
use Illuminate\Console\Command;

class ResetPayOrder extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'workOrder:reset-pay-order {shopCode}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '删除对应的门店的支付工单进件';

    public function handle()
    {
        $shopCode = $this->argument('shopCode');

        if (!$shopCode) {
            dd('$shopCode 不能为空');
        }

        $this->ask('请确认以上的门店编号,否则直接退出');

        $signOrder = OpenShopSignOrderModel::query()
                                           ->with('baseInfoRel')
                                           ->with('mainProcessRel')
                                           ->where('shopCode', $shopCode)
                                           ->where('status', '!=', 0)
                                           ->first();

        $workOrder = WorkOrderApplyMainModel::query()->where('shopId', $signOrder->mainProcessRel->shopId)
                                            ->where('problemChildId', 100)->first();

        $rows = WorkOrderApplyMainModel::query()->where('workOrderNo', $workOrder->workOrderNo)->update([
            'isDeleted' => 1
        ]);

        dd($rows);

    }
}
